﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////

#pragma once
#include <map>
#include <list>
#include "GmepBaseAlgorithm.h"
#include "IParameterValueStorage.h"
#include "IArc3d.h"
#include "QList"
#include "QMap"
#include "OwnerPtr.h"

namespace gnuf
{
    enum class AnnouncementLevel;
}

namespace gcmp
{
    class IDocument;   
    class IUiView;
    class IGraphicsNodeReference;
    class Vector3d;
    class ElementId;
    class IPickFilter;
    class IGraphicsNodeGroup;
    class IGraphicsElementShape;
    class IInstance;
    class IInstanceType;
    class Box3d;
    class ILine3d;
    class ILine2d;
    class IGraphicsStyle;
    class IParameter;
    class UniIdentity;
    class IModelView;
    class IParameterDefinitionLibrary;
    class IFamily;
    class IGroup;
    class ICurve3d;
}

class QWidget;
class QVariant;
struct GMEPMWAPWallInfo;
class GmepProductInfo;
namespace gmep
{
    enum class BathRoomApplianceType :int32_t;
    enum class MEPSystemClassification :Int32;

    struct GMEP_BASE_ALGORITHM_EXPORT DialogPropertyValueInfo
    {
        DialogPropertyValueInfo()
        {
            m_iValue = 0;
            m_dValueInBaseUnit = 0.0;
        }

        DialogPropertyValueInfo(std::wstring groupName, std::wstring propName, int iValue, double dValueInBase, std::wstring propertyValue, std::wstring propertyGuid)
        {
            m_groupName = groupName;
            m_propertyName = propName;
            m_propertyValue = propertyValue;
            m_iValue = iValue;
            m_propertyGuid = propertyGuid;
            m_dValueInBaseUnit = dValueInBase;
        }
        std::wstring m_groupName;
        std::wstring m_propertyName;
        std::wstring m_propertyValue;
        int m_iValue = 0; // int value or enum value,or bool value
        std::wstring m_propertyGuid;
        double m_dValueInBaseUnit = 0.0;
    };

    struct GMEP_BASE_ALGORITHM_EXPORT FamilyTypePropertyValueInfo
    {
        FamilyTypePropertyValueInfo()
        {
            Version = 1;
        }

        FamilyTypePropertyValueInfo(
            int version,
            const std::wstring& name,
            const std::wstring& id,
            const std::wstring& familyParam,
            const std::wstring& familyParamUnDrive,
            const std::map<std::wstring, std::map<std::wstring, DialogPropertyValueInfo>>&info)
        {
            Version = version;
            TypeName = name;
            TypeId = id;
            FamilyParam = familyParam;
            FamilyParamUnDrive = familyParamUnDrive;
            PropertyInfo = info;
        }
        int Version = 1;
        std::wstring TypeName;
        std::wstring TypeId;
        std::wstring FamilyParam;
        std::wstring FamilyParamUnDrive;
        std::map<std::wstring, std::map<std::wstring, DialogPropertyValueInfo>> PropertyInfo;
    };

    enum class ConnectorPosition : int32_t
    {
        e_NearestEnd = 0,
        e_FarthestEnd = 1,
        e_Nearest = 2,
        e_Farthest = 3,
    };
    struct GMEP_BASE_ALGORITHM_EXPORT GmepFamilyTypeInfo
    {
        GmepFamilyTypeInfo()
            : FamilyId(gcmp::ElementId::InvalidID)
            , FamilyName(L"")
            , FamilyFilePath(L"")
            , TwoDimPlaneFamilyPathName(L"")
            , TwoDimRightLeftElevationFamilyPathName(L"")
            , TwoDimFrontBackElevationFamilyPathName(L"")
            , FamilyCategoryId(L"")
            , FamilyCloudId(Int64(-1))
            , VersionNumber((int)1)
        {
        }

        gcmp::ElementId FamilyId;
        std::wstring FamilyName;
        std::wstring FamilyFilePath;

        std::wstring TwoDimPlaneFamilyPathName;
        std::wstring TwoDimRightLeftElevationFamilyPathName;
        std::wstring TwoDimFrontBackElevationFamilyPathName;
        std::wstring FamilyCategoryId;
        Int64 FamilyCloudId;
        int VersionNumber;
    };   
    
    class IMepDevice;
    class IMepCurve;
    class IGmepPropertyInfo;
    class IMepSystemType;
    class IMepSystem;
    class IMepCurveType;
    class IPipe;
    class IDuct;
    class IMepFitting;
    class IMepElement;
    class IConnector;
    class IMepInstance;
    class IGmepCategoryInfo;
    class GmepConnectorDisconnectShowTipsEventHandler;
    class INetworkUpdater;

    class GMEP_BASE_ALGORITHM_EXPORT BaseCommonUtils
    {
    public:       
        //旋转设备
        static void RotateDevice(gcmp::IDocument* pDoc, const gcmp::ElementId& eleId, const gcmp::Vector3d& pointOnRotationAxis, const gcmp::Vector3d& rotationAxisDirection, double angleInRadian);
        //设置偏移高度
        static void SetHeightOffSet(gmep::IMepDevice* pDevice, double dOffsetHeight);
        //设置实例参数
        static void SetInstanceParameters(gmep::IMepDevice* pDevice, const std::wstring& sParameterName, double dParameterValue);
        static void SetInstanceParameters(gcmp::IInstance* pIInstance, const std::wstring& sParameterName, double dParameterValue);
        static void SetInstanceParameters(gmep::IMepDevice* pDevice, const gcmp::UniIdentity& uid, double dParameterValue);
        static void SetInstanceParameters(gcmp::IInstance* pIInstance, const gcmp::UniIdentity& uid, double dParameterValue);
        static void SetTypeParameters(gmep::IMepDevice* pDevice, const std::wstring& sParameterName, double dParameterValue);
        static bool SetAllTypeParameters(gcmp::IDocument* pDocument, gcmp::IFamily* pFamily, const std::map<std::wstring, FamilyTypePropertyValueInfo>& allTypePropertyValueMap, gcmp::OwnerPtr<GmepProductInfo> opProductInfo);
        
        static gcmp::OwnerPtr<gcmp::IParameterValueStorage> GetParameterValueStorageByType(short iType, std::wstring strValue, double dValueInBase, int iValue);
        
        //设置类型参数, **对于有单位的属性，务必保证输入的参数值，是基准单位的值**
        static bool SetElementTypeParameters(gcmp::IInstanceType* pInstanceType, std::map<std::wstring, const gcmp::IParameterValueStorage *> propertyList,
            std::wstring familyParam=L"");
        // 由驱动参数列表字符串获得 参数-值map： familyParam: 保护半径=3000;喷头长度=60; 返回 <"保护半径",3000><"喷头长度",60 >
        static std::map<std::wstring, double> GetFamilyParamMap(const std::wstring familyParam);
        //设置实例参数, **对于有单位的属性，务必保证输入的参数值，是基准单位的值**
        static bool SetElementInstanceParameters(gcmp::IElement* pElement, std::map<std::wstring, gcmp::IParameterValueStorage *> propertyList, std::wstring familyParam = L"");

        //修改属性参数
        static bool ModifyElementInstanceParameters(gcmp::IElement *pElement, const std::map<std::wstring, gcmp::IParameterValueStorage *>& propertyList);
        // 将值为dValue， 单位标准码为 unitCode 的某属性值， 转换为软件的基准单位的值， 返回此属性是否有单位
        static bool ConvertDoubleValueInBaseUnit(gcmp::IDocument* pDocument, const gcmp::IParameterDefinitionLibrary* pLibrary,
            const std::wstring& proGuid, const std::map<std::wstring, short>& retUnitInfoMap, const double dValue, const std::wstring& unitCode, double& dValueInBase);
        
        //更新实例参数
        static void UpdateIntValueToInstancePropList(std::wstring strGuid,bool bValue, int iValue, double d, std::wstring strValue,std::map<std::wstring, gcmp::OwnerPtr<gcmp::IParameterValueStorage>>& instancePropList);

        static gcmp::OwnerPtr<gcmp::IGraphicsNodeGroup> TransferGRepToGGroup(gcmp::OwnerPtr<gcmp::IGraphicsElementShape> opGRep);
        static std::wstring RemoveBracket(std::wstring& strGuidwithBracket);
        static std::wstring RemoveBracket(const std::wstring& strGuidwithBracket);
        
        static void GetTemporaryDimensionPoint(gcmp::IUiView* pCurrentView, gcmp::IDocument* pDocument, const gcmp::UniIdentity &categoryId, const gcmp::Vector3d& curPoint, bool &isHorRef, gcmp::Vector3d &horPoint, bool &isVerRef, gcmp::Vector3d &verPoint, bool &isHorDevice, bool &isVerDecvice);
        static gcmp::IGraphicsStyle *GetDimensionData(gcmp::IDocument* pDocument);
        static void GetTemporaryDimensionGraphics(gcmp::IUiView* pCurrentView, gcmp::IDocument* pDoc, const gcmp::UniIdentity &categoryId, const gcmp::Vector3d& curPoint, const gcmp::IGraphicsStyle *pTempStyle, gcmp::IGraphicsElementShape *upTempGRep, gcmp::Vector3d &m_updatePoint);
        static void AddBoxToGraphics(gcmp::IGraphicsElementShape *pGraphicsElementShape, const gcmp::Box3d &box3d, std::vector<gcmp::OwnerPtr<gcmp::ILine3d>> &opLine3ds, const std::vector<gcmp::Vector3d> &vecPlacePoints, double angle, double dZoomFactor = 1.0);
        static bool CheckCommandCanbeUse();

        static bool IsDimensionCommandEnabled(const gcmp::IModelView* pModelView);

        /// \brief 预加载风口族；
        static bool PreLoadAirTerminalFamily(gcmp::IDocument* pDocument);
        static std::wstring  GetParameterDropDownListDisplayString(const gcmp::IDocument *pDoc, const gcmp::UniIdentity& uid, const gcmp::IParameterValueStorage* pStorage, bool& isDropdownValueList);

        static bool IsStandardCodeValveAndAccessory(const std::wstring& strStandardCode);

        //移除InstallationMethodParameter(明/暗装)
        static void RemoveInstallationMethodParameter(int installationType, std::map<std::wstring, gcmp::OwnerPtr<gcmp::IParameterValueStorage>>& instancePropertyList);

        // 单机时使用公共库id， 协同时使用协同项目id
        static bool IsUsePublicId();


        //数组反向
        template<typename T>
        static void Revert(std::vector<T>& vec) 
        {
            for (int i = 0; i < vec.size() / 2; ++i)
            {
                T temp = vec[vec.size() - i - 1];
                vec[vec.size() - i - 1] = vec[i];
                vec[i] = temp;
            }
        };

        // 获取当前app的版本号， 如0.34
        static std::wstring GetCurrentAppShortVersion();

    static bool SetPropertyToProductInfo(const std::map<std::wstring, const IGmepPropertyInfo*>& propertyMap, const std::map<std::wstring, DialogPropertyValueInfo>& propertyValueMap, gcmp::OwnerPtr<GmepProductInfo>& opProductInfo);


    //获取卫浴设备类型
    static BathRoomApplianceType GetBathRoomApplianceType(const gcmp::IElement* pTypeElement);
    static BathRoomApplianceType GetBathRoomApplianceType(const std::wstring wsBathRoomApplianceType);

    static const gmep::MEPSystemClassification GetMepElementSystemClass(gcmp::IDocument * pDoc, const gmep::IMepElement* pMepCurve);
    static gmep::MEPSystemClassification GetMepElementSystemClass(gcmp::IDocument * pDoc, gmep::IMepElement* pMepCurve);
    static const gmep::MEPSystemClassification GetMepElementSystemClass(gcmp::IDocument * pDoc, const gcmp::IElement* pElement);

    static const std::wstring GetMepElementSystemTypeName(gcmp::IDocument * pDoc, gmep::IMepElement * pMepCurve);
    static const std::wstring GetMepElementSystemTypeName(gcmp::IDocument * pDoc, const gmep::IMepElement* pMepCurve);

    static const gmep::IMepSystemType* GetMepElementSystemType(gcmp::IDocument * pDoc, const gmep::IMepElement * pMepCurve);
    static gmep::IMepSystemType* GetMepElementSystemType(gcmp::IDocument * pDoc, gmep::IMepElement * pMepCurve);

    /// \brief 获得同位置同系统的立管（垂直投影偏差10mm内）
    /// \param pMepCurve 基准立管
    /// \return std::vector<gmep::IPipe*> 同位置立管集合
    static std::vector<IPipe*> GetSamePositonRaisePipes(const IPipe* pPipe);

    // 获取connector数组
    // bResult: 是否成功；如果false，则获取到的为临时变量；如果true，则获取到底层返回的数据
    static std::vector<gcmp::OwnerPtr<gmep::IConnector>>& GetMepInstanceConnectors(gmep::IMepInstance* pMepInstance, bool& bResult);

    // bResult: 是否成功；如果false，则获取到的为临时变量；如果true，则获取到底层返回的数据
    static const std::vector<gcmp::OwnerPtr<gmep::IConnector>>& GetMepInstanceConnectors(const gmep::IMepInstance* pMepInstance, bool& bResult);

    static std::vector<gmep::IConnector*> GetMepInstanceConnectors(gmep::IMepInstance* pMepInstance);
    static std::vector<const gmep::IConnector*> GetMepInstanceConnectors(const gmep::IMepInstance* pMepInstance);

    static const std::vector<gcmp::OwnerPtr<gmep::IConnector>>& GetMepCurveConnectors(const gmep::IMepCurve* pMepCruve, bool& bResult);
    static std::vector<gcmp::OwnerPtr<gmep::IConnector>>& GetMepCurveConnectors(gmep::IMepCurve* pMepCruve, bool& bResult);

    // 获取坐标系
    // connId 为-1时，获取第一个。connId>-1时，根据connId获取。
    static bool GetMepInstanceCoordinate(const gmep::IMepInstance* pMepInstance, int connId, gcmp::Coordinate3d& coord);
    static bool GetMepCurveCoordinate(gmep::IMepCurve* pMepCruve, int connId, gcmp::Coordinate3d& coord);
    static bool GetMepCurveCoordinateByPoint(gmep::IMepCurve* pMepCruve, ConnectorPosition ePos, gcmp::Vector3d& pnt, gcmp::Coordinate3d& coord);

    //获得管件连接的管线（会跨越相邻管件）
    static std::vector<const gmep::IMepCurve*> GetMepInstanceConnectMepCurve(gcmp::IDocument* pdoc, 
        const gmep::IMepInstance* mepInstance, QList<const gmep::IMepInstance*>& mepInstances, bool deleteInstance = false);

    //获得管件连接的管线（会跨越相邻管件）
    static std::vector<gmep::IMepCurve*> GetMepInstanceConnectMepCurve(gcmp::IDocument* pdoc, 
        gmep::IMepInstance* mepInstance, QList<const gmep::IMepInstance*>& mepInstances, bool deleteInstance = false);

    //角度制         //获得标准角度，如果为非标准角度，则查找比这个大的标准角度，即15的倍数的角度
    static double GetStandardAngle(double angle, bool isAutoConnect = true);

    //获得指定视图的默认标高
    static gcmp::ElementId GetDefaultLevelElementId(const gcmp::IDocument* pdoc, const gcmp::IModelView* pModelView);
    //\brief 传入待转换的当前值，以及单位的uid，传出带有单位的 向内部基准单位转换过后的值字符串
    static bool GetStringByOriginValue(const gcmp::IDocument *pDoc, double dValue, const gcmp::UniIdentity unitUid, QString &qsText);

    static void SetPropertyAndInstanTypeProductInfo(const std::wstring& databaseName, const std::wstring& tableName, const std::wstring& productName, gcmp::OwnerPtr<GmepProductInfo>& prodInfo, const std::wstring& categoryId = L"");

    static bool GetOneProductInfo(const std::wstring& databaseName, const std::wstring& tableName, const std::wstring& productName, gcmp::OwnerPtr<GmepProductInfo>& prodInfo, const std::wstring& categoryId = L"");
    //获取加载项目样板族文件相关信息
    static bool GetOneProductInfoForLoadTemplateFamily(const std::wstring& databaseName, const std::wstring& tableName, const std::wstring& productName, gcmp::OwnerPtr<GmepProductInfo>& prodInfo, const std::wstring& categoryId, bool bUsePublicId);
    // 获取所有族类型信息
    static bool GetOneProductInfoForLoadTemplateFamily(const std::wstring& databaseName, const std::wstring& tableName,
        const std::wstring& productName, const std::wstring & currentProductFolderPath,const std::wstring & currentProduct3DFolderPath,
        const std::wstring & currentProduct2DFolderPath,gcmp::OwnerPtr<GmepProductInfo>& prodInfo,
        std::map<std::wstring, gmep::FamilyTypePropertyValueInfo>& allTypePropertyValueMap, bool bUsePublicId);

    //加载族，创建族类型，返回familyId和instanceTypeId，如果不是gmep专业构件，bGmepComponent传false
    static bool LoadFamilyType(gcmp::IDocument* pDocument, const GmepProductInfo* productInfo,
        gcmp::ElementId &familyId, gcmp::ElementId& pRetInstanceType, bool bGmepComponent = true);
    //加载族类型，传入族完整路径，及category，返回familyid和instanceTypeId，如果不是gmep专业构件，bGmepComponent传false
    static bool LoadFamilyType(gcmp::IDocument* pDocument, std::wstring familyFullPath, std::wstring categoryUid,
        gcmp::ElementId &familyId, gcmp::ElementId& pRetInstanceType, bool bGmepComponent = true);
    //加载族，创建族类型，返回familyId和instanceTypeId，如果不是gmep专业构件，bGmepComponent传false
    static bool LoadFamilyType(gcmp::IDocument* pDocument, const GmepProductInfo* productInfo,
        gcmp::ElementId & familyId, bool bGmepComponent = true, bool isShowProgressBar = true);

    // 加载一个构件到当前文档，包含所有族类型，使用矫正构件名
    // familyName为项目产品库中的构件名， uniqueFamilyName为本文档的矫正构件名（_1）， 可以为空，或者与familyName相同
    // bLoadFromPublicLibrary 为true 使用公共库下载的产品库，为false 使用项目库或本地库
    static bool LoadAllFamilyType(gcmp::IDocument* pDocument, const std::wstring& familyName,
        const std::wstring& uniqueFamilyName, const std::wstring& categoryStandardCode,
        bool bUsePublicId, bool bLoadFromPublicLibrary = false, bool isShowProgressBar = true);

    // 通过version,islatest过滤产品
    static QList<QMap<QString, QString>> ProductVersionFilterList(QList<QMap<QString, QString>> productList);

    /// \brief 更新product图例路径信息
    /// \param dbPath 数据库文件路径
    /// \param opProductInfo product对象，需要将对应的id写进对应的path
    /// \return  返回更新成功状态
    static bool UpdateProductInfoPlaceholderPathInfo(const std::wstring& dbPath, const std::wstring & currentProduct2DFolderPath, gcmp::OwnerPtr<GmepProductInfo>& opProductInfo);

    /// \brief 更新product 中id和version 信息，已经相关图例id
    /// \param dbPath 数据库文件路径
    /// \param queryStatement sql语句
    /// \param opProductInfo product对象
    /// \return 
    static bool UpdateProductInfoIdAndVersion(const std::wstring& dbPath, const std::wstring& queryStatement, gcmp::OwnerPtr<GmepProductInfo>& opProductInfo);

    static std::map<std::wstring, const IGmepPropertyInfo *> GetPropertyInfoData(const std::wstring& databaseName,
        const std::wstring& productName, const std::wstring& categoryId, const std::wstring& tableName,
        gcmp::OwnerPtr<GmepProductInfo>& prodInfo, gcmp::OwnerPtr<IGmepCategoryInfo>& opCategory,
        std::map<std::wstring, DialogPropertyValueInfo>& propertyValueMap, QVector<QStringList>& vecStringList);

    static bool GetAllTypePropertyInfoData(const std::wstring& databaseName, const std::wstring& productName,
        gcmp::OwnerPtr<GmepProductInfo>& prodInfo,std::map<std::wstring, gmep::FamilyTypePropertyValueInfo>& typesPropertyInfo);

    static std::map<std::wstring, std::map<std::wstring, DialogPropertyValueInfo>> GetPropertyValueFromSpec(const std::wstring& databaseName, std::wstring categoryId, gmep::IGmepCategoryInfo* pCurCategory, const std::wstring& tableName, const std::wstring& dataId);

    static std::map<std::wstring, gmep::FamilyTypePropertyValueInfo> GetAllTypePropertyValueFromSpec(const std::wstring& databaseName, gmep::IGmepCategoryInfo* pCurCategory, const std::wstring& tableName, const std::wstring& dataId, int version = 1);
    static bool GetCategoryPropertyListInfo(std::map<std::wstring, const IGmepPropertyInfo *> propertyList, std::vector<std::vector<std::wstring>>& propertiesVec, QStringList& propertyNames, QStringList& inUseColumnNames, QStringList& unitColumnCodes);
    static std::map<std::wstring, std::map<std::wstring, DialogPropertyValueInfo>> GetOneTypePropertyValue(std::map<std::wstring, const IGmepPropertyInfo *> propertyList, const std::vector<std::vector<std::wstring>>& propertiesVec, const std::map<std::wstring, short>& retUnitInfoMap, const QStringList& properties, const QStringList& inUses, const QStringList& unitCodes);
    static bool GetOneProperty(const  IGmepPropertyInfo * pProperty, const std::vector<std::wstring>& propertyInfo, const std::map<std::wstring, short>& retUnitInfoMap, const std::wstring& propertyValue, bool bInUse, const std::wstring& unitCode, DialogPropertyValueInfo& info);

    // 得到设备的位置和方向
    static bool GetMepDevicePosAndDir(const gmep::IMepInstance* pMepDevice, gcmp::Vector3d& pntMepDevice, gcmp::Vector3d& dirMepDevice, gcmp::Vector3d& dirNormal);
    static bool GetMepDevicePosAndDir(const gmep::IMepDevice* pMepDevice, gcmp::Vector3d& pntMepDevice, gcmp::Vector3d& dirMepDevice, gcmp::Vector3d& dirNormal);
    static bool GetMepDevicePosAndDir(const gcmp::IDocument* pDoc, const gcmp::ElementId &mepDeviceId, gcmp::Vector3d& pntMepDevice, gcmp::Vector3d& dirMepDevice, gcmp::Vector3d& dirNormal);
    static bool GetMepDevicePosAndDir(const gcmp::IElement* pElement, gcmp::Vector3d& pntMepDevice, gcmp::Vector3d& dirMepDevice, gcmp::Vector3d& dirNormal);

    static bool GetCustomStringByOriginValue(const gcmp::IDocument *pDoc, double dValue, const gcmp::UniIdentity unitUid, int customUnit, QString &qsText);

    //通过链接文档构件来获取其在主文档中对应的代理对象Id；
    static gcmp::ElementId GetProxyElementIdInMainDocumentByLinkElement(const gcmp::IDocument* pMainDocument, const gcmp::IElement* pLinkElement);

    static const gmep::MEPSystemClassification GetConnSystemClassification(gmep::IConnector * conn);
    static const gmep::MEPSystemClassification GetConnSystemClassification(const gmep::IConnector * conn);

    //提示信息，内部会调用gcmp平台消息与新UI框架两个消息提示
    static bool PostNotification(gnuf::AnnouncementLevel status, const std::wstring& wsText);

    static const QVariant ConvertElementIdToQVariant(const gcmp::ElementId& id);
    static const gcmp::ElementId ConvertQVariantToElementId(const QVariant& idData);

    /// \brief 管道方向
    /// 
    /// \param pMepCurve 机电曲线对象指针
    /// \return Vector3d
    static gcmp::Vector3d GetMepCurveDirection(const gmep::IMepCurve *pMepCurve);

    ///\brief 通过单位管理转换单位
    //************************************
    // Method:    GetCurentUnitByUnitUid
    // FullName:  BaseInteractionUtils::GetCurentUnitByUnitUid
    // Access:    public static 
    // Returns:   void
    // Qualifier:
    // Parameter: const gcmp::IDocument * pDoc
    // Parameter: const gcmp::UniIdentity & uid 
    // Parameter: QString sInValue 传入的 string 值
    // Parameter: QString & sOutValue 传出的需要显示的字符串
    // Parameter: double & dValue 传出的基于基准单位的值
    //************************************
    static void GetCurrentUnitByUnitUid(const gcmp::IDocument *pDoc, const gcmp::UniIdentity & uid, QString sInValue, QString& sOutValue, double &dValue);

    ///\brief 通过单位管理转换单位
    //************************************
    // Method:    GetCurentUnitByUnitUid
    // FullName:  BaseInteractionUtils::GetCurentUnitByUnitUid
    // Access:    public static 
    // Returns:   void
    // Qualifier:
    // Parameter: const gcmp::IDocument * pDoc
    // Parameter: const gcmp::UniIdentity & uid 
    // Parameter:  double dInValue 传入的 DOUBLE 值
    // Parameter: QString & sOutValue 传出的需要显示的字符串
    //************************************
    static void GetCurrentUnitByUnitUid(const gcmp::IDocument *pDoc, const gcmp::UniIdentity & uid, double dInValue, QString& sOutValue);

    ///\brief 通过单位管理转换单位
    //************************************
    // Method:    GetCurentUnitByUnitUid
    // FullName:  BaseInteractionUtils::GetCurentUnitByUnitUid
    // Access:    public static 
    // Returns:   void
    // Qualifier:
    // Parameter: const gcmp::IDocument * pDoc
    // Parameter: const gcmp::UniIdentity & uid 
    // Parameter:  double dInValue 传入的 DOUBLE 值
    // Parameter: double & dOutValue  传出的 DOUBLE 值
    //************************************
    static void GetCurrentUnitByUnitUid(const gcmp::IDocument *pDoc, const gcmp::UniIdentity & uid, double dInValue, double& dOutValue);

    ///\brief 获得当前单位的符号
    static std::wstring GetCurrentUnitCharacter(const gcmp::IDocument *pDoc, const gcmp::UniIdentity & uid);

    ///\brief 获得当前单位的精度值
    static double GetCurrentUnitPrecision(const gcmp::IDocument *pDoc, const gcmp::UniIdentity & uid);


    ///\brief获得当前单位的值不包含符号
    static std::wstring GetUnitStringNoWithSymbol(const gcmp::IDocument *pDoc, const gcmp::UniIdentity & uid, double dInValue);

    ///\ brief 获取单位转换后的值
    static bool GetValueByString(gcmp::IDocument *pDoc, QString qsText, double &dValue);

    static void SetNewParamValue(gcmp::IParameter*& newParam, const gcmp::IParameterValueStorage* inputParam);

    //以下两个方法组合使用，不可分开调用。
    static bool RegisterConnectorDisconnectShowTipsEventHandler(const gcmp::IDocument* pActiveDocument, const std::vector<gcmp::ElementId>& vcElementIds
        , std::vector<std::pair<gcmp::IDocument*, gmep::GmepConnectorDisconnectShowTipsEventHandler*>>& vcErrorHandlers
        , std::vector<gmep::INetworkUpdater*>& pNetWorkUpdaters, std::function<int()> dlg, bool bCloseNetWorkUpdater = false);
    static bool RegisterConnectorDisconnectShowTipsEventHandler(const std::map<gcmp::RuntimeId, gcmp::IDocument*>& mapRuntimeIdAndDoc
        , std::vector<std::pair<gcmp::IDocument*, gmep::GmepConnectorDisconnectShowTipsEventHandler*>>& vcErrorHandlers
        , std::vector<gmep::INetworkUpdater*>& vcNetWorkUpdaters, std::function<int()> dlg, bool bCloseNetWorkUpdater = false);
    static void UnRegisterConnectorDisconnectShowTipsEventHandler(std::vector<std::pair<gcmp::IDocument*, gmep::GmepConnectorDisconnectShowTipsEventHandler*>>& vcErrorHandler
        , std::vector<gmep::INetworkUpdater*>& pNetWorkUpdaters);
   
    static bool CanElementBeMoved(const gcmp::IDocument * pDocument, const gcmp::ElementId & elementId);



    static void MarkTypeParameterUpdate(gcmp::IInstanceType* pInstanceType);
    private:
        //static std::wstring Insert2DFamilyTo3DFamily(const std::wstring& familyName, const std::wstring& s3DFamilyFile, const Gmep2DFamilyInfo* p2DFamilyInfo);
        static bool IsHVAC(const std::wstring& sSelectCategoryId);
        static bool IsWater(const std::wstring& sSelectCategoryId);
        
        static bool GetPickedAllGraphicsNode(gcmp::IUiView * pCurrentView, const gcmp::Vector3d & pos, double dPickTolerance,
            const gcmp::IPickFilter * pPickFilter, std::vector<gcmp::OwnerPtr<gcmp::IGraphicsNodeReference>>& arrGNodeReference);
        static bool GetLinePolygonIntersect(const gcmp::ILine2d *line, const std::vector<gcmp::ILine2d *> tempLines);     
        static void GetTemporaryDimensionElement(gcmp::IDocument* pDocument, const std::vector<const gcmp::IGraphicsElementShape*> &GraphicsElementShapes, gcmp::UniIdentity deviceId, const gcmp::Vector3d& curPoint, std::vector<GMEPMWAPWallInfo> &wallInfos, std::vector<const gcmp::IElement*> &pDeviceElements);
        static bool GetTemporaryDimensionWallInfo(const gcmp::IGraphicsElementShape*pGraphicsElementShape, const gcmp::IElement *pElement, GMEPMWAPWallInfo &wallInfo);
        /// \brief 通过传入的图例id信息查询相关图例名称、来源，并构造返回图例路径
        ///\param dbPath db文件路径 
        /// \param placeholderPathInfo id为key，value为gac路径
        /// \return 
        static bool Get2dGacPathInfo(const std::wstring& dbPath, const std::wstring& currentProduct2DFolderPath, std::map<std::wstring, std::wstring>& placeholderPathInfo);
       
    };  


}
